[##include file="common/header.tpl.php"##]
[##include file="common/nav.tpl.php"##]


<div id="main">
	<p><a href="[##$adminurl##]/?m=factory&a=event">返回随机事件列表</a></p>

	<form id="eventadd_form" method="POST" style="margin-top:20px;">
		<table class="form_table">
			<tr>
				<td width="70px">事件名</td>
				<td><input type="text" name="name" value="[##if !empty($event.name)##][##$event.name|escape##][##/if##]" style="width:300px" /></td>
			</tr>
			<tr>
				<td>发生地点</td>
				<td>
					<select name="place">
						<option value="">== 选择 == </option>
						[##foreach from=$places key=place item=place_name##]
						<option value="[##$place##]"[##if !empty($event.place) && $event.place == $place##] selected="selected"[##/if##]>[##$place_name##]</option>
						[##/foreach##]
					</select>
				</td>
			</tr>
			<tr>
				<td>发生概率</td>
				<td><input type="text" name="probability" value="[##if !empty($event.probability)##][##$event.probability##][##/if##]" style="width:40px" /> %</td>
			</tr>

			<tr>
				<td colspan="2" style="padding-top:15px"><strong>====== 引导 ======</strong></td>
			</tr>
			<tr>
				<td valign="top">文字</td>
				<td><textarea name="guide_text" style="width:600px; height:100px;">[##if !empty($event.guide.text)##][##$event.guide.text|escape##][##/if##]</textarea></td>
			</tr>
			<tr>
				<td>下一步按钮</td>
				<td><input type="text" name="guide_ok" value="[##if !empty($event.guide.ok)##][##$event.guide.ok|escape##][##/if##]" style="width:300px" /></td>
			</tr>
			<tr>
				<td>取消按钮</td>
				<td><input type="text" name="guide_cancel" value="[##if !empty($event.guide.cancel)##][##$event.guide.cancel|escape##][##/if##]" style="width:300px" /></td>
			</tr>

			<tr>
				<td colspan="2" style="padding-top:15px"><strong>====== 信息 ======</strong></td>
			</tr>
			<tr>
				<td valign="top">文字</td>
				<td><textarea name="info_text" style="width:600px; height:100px;">[##if !empty($event.info.text)##][##$event.info.text|escape##][##/if##]</textarea></td>
			</tr>
			<tr>
				<td>下一步按钮</td>
				<td><input type="text" name="info_ok" value="[##if !empty($event.info.ok)##][##$event.info.ok|escape##][##/if##]" style="width:300px" /></td>
			</tr>
			<tr>
				<td>取消按钮</td>
				<td><input type="text" name="info_cancel" value="[##if !empty($event.info.cancel)##][##$event.info.cancel|escape##][##/if##]" style="width:300px" /></td>
			</tr>



			<tr>
				<td colspan="2" style="padding-top:15px"><strong>====== 结果 1 ======</strong></td>
			</tr>
			<tr>
				<td>概率</td>
				<td><input type="text" name="result_probability[]" value="[##if !empty($event.result[0].probability)##][##$event.result[0].probability##][##/if##]" style="width:40px" /> %</td>
			</tr>
			<tr>
				<td valign="top">文字</td>
				<td><textarea name="result_text[]" style="width:600px; height:100px;">[##if !empty($event.result[0].text)##][##$event.result[0].text|escape##][##/if##]</textarea></td>
			</tr>
			<tr>
				<td>奖罚</td>
				<td>
					<select name="result_gain_type[]">
						<option value="">== 选择 == </option>
						<option value="currency"[##if !empty($event.result[0].gain_type) && $event.result[0].gain_type == 'currency'##] selected="selected"[##/if##]>银币(疯狂工厂的货币)</option>
						<option value="money"[##if !empty($event.result[0].gain_type) && $event.result[0].gain_type == 'money'##] selected="selected"[##/if##]>金币(社区内的货币，等价于人民币)</option>
						<option value="hp"[##if !empty($event.result[0].gain_type) && $event.result[0].gain_type == 'hp'##] selected="selected"[##/if##]>体力</option>
						<option value="item"[##if !empty($event.result[0].gain_type) && $event.result[0].gain_type == 'item'##] selected="selected"[##/if##]>道具</option>
					</select>
					&nbsp; &nbsp; 额度(或ID) <input type="text" name="result_gain_num[]" value="[##if !empty($event.result[0].gain_num)##][##$event.result[0].gain_num##][##/if##]" style="width:80px" />
				</td>
			</tr>
			<tr>
				<td>确认按钮</td>
				<td><input type="text" name="result_ok[]" value="[##if !empty($event.result[0].ok)##][##$event.result[0].ok|escape##][##/if##]" style="width:300px" /></td>
			</tr>



			<tr>
				<td colspan="2" style="padding-top:15px"><strong>====== 结果 2 ======</strong></td>
			</tr>
			<tr>
				<td>概率</td>
				<td><input type="text" name="result_probability[]" value="[##if !empty($event.result[1].probability)##][##$event.result[1].probability##][##/if##]" style="width:40px" /> %</td>
			</tr>
			<tr>
				<td valign="top">文字</td>
				<td><textarea name="result_text[]" style="width:600px; height:100px;">[##if !empty($event.result[1].text)##][##$event.result[1].text|escape##][##/if##]</textarea></td>
			</tr>
			<tr>
				<td>奖罚</td>
				<td>
					<select name="result_gain_type[]">
						<option value="">== 选择 == </option>
						<option value="currency"[##if !empty($event.result[1].gain_type) && $event.result[1].gain_type == 'currency'##] selected="selected"[##/if##]>银币(疯狂工厂的货币)</option>
						<option value="money"[##if !empty($event.result[1].gain_type) && $event.result[1].gain_type == 'money'##] selected="selected"[##/if##]>金币(社区内的货币，等价于人民币)</option>
						<option value="hp"[##if !empty($event.result[1].gain_type) && $event.result[1].gain_type == 'hp'##] selected="selected"[##/if##]>体力</option>
						<option value="item"[##if !empty($event.result[1].gain_type) && $event.result[1].gain_type == 'item'##] selected="selected"[##/if##]>道具</option>
					</select>
					&nbsp; &nbsp; 额度(或ID) <input type="text" name="result_gain_num[]" value="[##if !empty($event.result[1].gain_num)##][##$event.result[1].gain_num##][##/if##]" style="width:80px" />
				</td>
			</tr>
			<tr>
				<td>确认按钮</td>
				<td><input type="text" name="result_ok[]" value="[##if !empty($event.result[1].ok)##][##$event.result[1].ok|escape##][##/if##]" style="width:300px" /></td>
			</tr>



			<tr>
				<td colspan="2" style="padding-top:15px"><strong>====== 结果 3 ======</strong></td>
			</tr>
			<tr>
				<td>概率</td>
				<td><input type="text" name="result_probability[]" value="[##if !empty($event.result[2].probability)##][##$event.result[2].probability##][##/if##]" style="width:40px" /> %</td>
			</tr>
			<tr>
				<td valign="top">文字</td>
				<td><textarea name="result_text[]" style="width:600px; height:100px;">[##if !empty($event.result[2].text)##][##$event.result[2].text|escape##][##/if##]</textarea></td>
			</tr>
			<tr>
				<td>奖罚</td>
				<td>
					<select name="result_gain_type[]">
						<option value="">== 选择 == </option>
						<option value="currency"[##if !empty($event.result[2].gain_type) && $event.result[2].gain_type == 'currency'##] selected="selected"[##/if##]>银币(疯狂工厂的货币)</option>
						<option value="money"[##if !empty($event.result[2].gain_type) && $event.result[2].gain_type == 'money'##] selected="selected"[##/if##]>金币(社区内的货币，等价于人民币)</option>
						<option value="hp"[##if !empty($event.result[2].gain_type) && $event.result[2].gain_type == 'hp'##] selected="selected"[##/if##]>体力</option>
						<option value="item"[##if !empty($event.result[2].gain_type) && $event.result[2].gain_type == 'item'##] selected="selected"[##/if##]>道具</option>
					</select>
					&nbsp; &nbsp; 额度(或ID) <input type="text" name="result_gain_num[]" value="[##if !empty($event.result[2].gain_num)##][##$event.result[2].gain_num##][##/if##]" style="width:80px" />
				</td>
			</tr>
			<tr>
				<td>确认按钮</td>
				<td><input type="text" name="result_ok[]" value="[##if !empty($event.result[2].ok)##][##$event.result[2].ok|escape##][##/if##]" style="width:300px" /></td>
			</tr>



			<tr>
				<td colspan="2" style="padding-top:15px"><strong>====== 结果 4 ======</strong></td>
			</tr>
			<tr>
				<td>概率</td>
				<td><input type="text" name="result_probability[]" value="[##if !empty($event.result[3].probability)##][##$event.result[3].probability##][##/if##]" style="width:40px" /> %</td>
			</tr>
			<tr>
				<td valign="top">文字</td>
				<td><textarea name="result_text[]" style="width:600px; height:100px;">[##if !empty($event.result[3].text)##][##$event.result[3].text|escape##][##/if##]</textarea></td>
			</tr>
			<tr>
				<td>奖罚</td>
				<td>
					<select name="result_gain_type[]">
						<option value="">== 选择 == </option>
						<option value="currency"[##if !empty($event.result[3].gain_type) && $event.result[3].gain_type == 'currency'##] selected="selected"[##/if##]>银币(疯狂工厂的货币)</option>
						<option value="money"[##if !empty($event.result[3].gain_type) && $event.result[3].gain_type == 'money'##] selected="selected"[##/if##]>金币(社区内的货币，等价于人民币)</option>
						<option value="hp"[##if !empty($event.result[3].gain_type) && $event.result[3].gain_type == 'hp'##] selected="selected"[##/if##]>体力</option>
						<option value="item"[##if !empty($event.result[3].gain_type) && $event.result[3].gain_type == 'item'##] selected="selected"[##/if##]>道具</option>
					</select>
					&nbsp; &nbsp; 额度(或ID) <input type="text" name="result_gain_num[]" value="[##if !empty($event.result[3].gain_num)##][##$event.result[3].gain_num##][##/if##]" style="width:80px" />
				</td>
			</tr>
			<tr>
				<td>确认按钮</td>
				<td><input type="text" name="result_ok[]" value="[##if !empty($event.result[3].ok)##][##$event.result[3].ok|escape##][##/if##]" style="width:300px" /></td>
			</tr>


			<tr>
				<td colspan="2" style="text-align:center; padding-top:30px;">
					[##if !empty($event.id)##]<input type="hidden" name="event_id" value="[##$event.id##]" />[##/if##]
					<button type="button" class="submit_button" id="eventadd_submit">提交</button>
				</td>
			</tr>

		</table>
	</form>
</div>

<script type="text/javascript">
// 绑定表单提交事件
$('#eventadd_submit').click(function() {
	var submit_url = '[##$adminurl##]/?m=factory&a=eventadd_do';

	$.post(submit_url , $('#eventadd_form').serialize() , function(d) {
		if(d.code) return alert(d.msg);

		alert(d.msg);
		window.location.href = '?m=factory&a=event';
	} , 'json');

});
</script>

[##include file="common/footer.tpl.php"##]